{extend name="index/public" /}

{block name="content"}
<form class="layui-form" action="">
    <div class="layui-form-item">
        <label class="layui-form-label">数据缓存</label>
        <div class="layui-input-inline">
            <input type="text" class="layui-input" value="{$date1}" id="date1" placeholder=" - ">
        </div>
        <div class="layui-input-inline">
            <button class="layui-btn my-btn my-btn-sm" type="button" id="send1">发送</button>
        </div>
    </div>
</form>
{/block}

{block name="css"}
{/block}

{block name="js"}
<script>
    layui.use(['table','laydate'], function(){
        var table = layui.table
            ,$ = layui.$
            ,form = layui.form
            ,load = null
            ,laydate = layui.laydate;

        $('#layui-loading').hide();

        laydate.render({
            elem: '#date1'
            ,type: 'month'
            ,range: true
            ,value: ''
            ,min: '2016-01-01'
            ,max: 0
            ,format: 'yyyy-MM'
        });

        $('#send1').click(function(){
            layer.confirm('确定要缓存数据吗？', {offset: '250px'}, function(index){
                var load = layer.load();
                $.post('{:url("Show/dataBuffer")}',{secret:'qt5iorev42rk*^', date:$('#date1').val()}, function(json){
                    layer.close(load);
                    if(json.code==0){
                        layer.msg(json.msg, {icon: 1, time:1000})
                    }else{
                        layer.msg(json.msg, {icon: 0, time:1000});
                    }
                }, 'JSON').error(function(){
                    layer.close(load);
                    layer.msg('连接超时，请联系后台管理员', {icon: 2, time:3000});
                });
            });
        })
    });
</script>
{/block}